package edu.sctu.java.advanced.pattern.builder;

public class User {

    private String name;
    private int age;
    private String phone;

    private User() {

    }

    public static class Builder implements IBuilder<User> {
        private User user;

        public Builder() {
            this.user = new User();
        }

        public Builder name(String name) {
            this.user.name = name;
            return this;
        }

        public Builder age(int age) {
            this.user.age = age;
            return this;
        }

        public Builder phone(String phone) {
            this.user.phone = phone;
            return this;
        }

        @Override
        public User build() {
            return this.user;
        }
    }

    public static void main(String[] args) {
        User u = new User.Builder()
                .name("chen")
                .age(12)
                .phone("183")
                .build();

        System.out.println(String.join(" - ",
                u.name,
                String.valueOf(u.age),
                u.phone));
    }
}
